package com.pretty.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pretty.test.controller.pets.station.dto.StationPageDTO;
import com.pretty.test.controller.pets.station.vo.StationListVO;
import com.pretty.test.controller.pets.station.vo.StationPageVO;
import com.pretty.test.controller.pets.station.wrapper.StationListVOWrapper;
import com.pretty.test.entity.PetsStation;
import com.pretty.test.mapper.PetsStationMapper;
import com.pretty.test.service.IPetsStationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pretty.test.utils.otherutils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 驿站服务实现类
 * @author dujianyu
 * @since 2021-04-02
 */
@Service
public class PetsStationServiceImpl extends ServiceImpl<PetsStationMapper, PetsStation> implements IPetsStationService {

    @Override
    public IPage<StationPageVO> selectStationPage(Page<StationPageVO> page, StationPageDTO dto) {
        return baseMapper.selectStationPage(page,dto);
    }

    @Override
    public List<StationListVO> getStationList(String stationName) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("is_deleted",0);
        queryWrapper.eq("station_stats",2);
        queryWrapper.like(!Func.isBlank(stationName),"station_name", stationName);
        queryWrapper.orderByDesc("create_time");
        return StationListVOWrapper.build().listVO(baseMapper.selectList(queryWrapper));
    }
}
